/*
============================================================================
 Name        : pd_timer.cpp
 Author      : Jian(raphyer@hotmail.com)
 Version     :
 Copyright   : GPL
 Description : pd_timer.cpp - source file
============================================================================
*/

// INCLUDE FILES

#include "pd_timer.h"

#include "PdTimer.h"


pd_timer* pd_timer_create(pd_timer_type type) 
{
    pd_timer* timer = NULL ;

    TRAPD(err, timer = (pd_timer*)CPdTimer::NewL(type)) ;

    if (err != KErrNone) 
    {
        DD_LOG("pd_timer_create error = %d", timer) ;
        return DD_NULL ;
    }

    return timer ;
}

void pd_timer_destroy(pd_timer* timer) 
{
    __DD_ASSERT_DEFENSE(timer, return) ;
    
    CPdTimer* sTimer = (CPdTimer*)timer ;
    delete sTimer ;
}

int pd_timer_start(pd_timer* timer, DD_UINT time_millisecond, pd_timer_callback callback, void* ptr) 
{
    __DD_ASSERT_DEFENSE(timer && callback, return -1) ;

    CPdTimer* sTimer = (CPdTimer*)timer ;

    sTimer->Start(time_millisecond, callback, ptr) ;

    return 0 ;
}

int pd_timer_stop(pd_timer* timer) 
{
    __DD_ASSERT_DEFENSE(timer, return -1) ;

    CPdTimer* sTimer = (CPdTimer*)timer ;

    sTimer->Stop() ;

    return 0 ;
}

/* End of File */
